<template>
  <el-row class="tablediv">
    <el-table :data="data" style="width: 100%" @row-click="cellxiangqing">
      <el-table-column v-if="titleriqi" fixed :label="titleriqi" width="50" align="center">
        <template slot-scope="scope">
          <div class="datadiv">{{ scope.row.dateStr }}</div>
        </template>
      </el-table-column>
      <el-table-column :prop="propname" :label="titlename" align="left"></el-table-column>
      <el-table-column :prop="proptime" :label="titletime" width="200" fixed="right"></el-table-column>
    </el-table>
    <el-row type="flex" justify="center" style="width: 100%;margin-top: 30px;">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pagedangqianye"
        :page-size="15"
        layout="prev, pager, next, jumper"
        :total="total"
        :hide-on-single-page="isPage"
        prev-text="上一页"
        next-text="下一页"
      ></el-pagination>
    </el-row>
  </el-row>
</template>

<script>
export default {
  name: 'WLNewsTable',
  props: {
    Newdata: {
      type: Array,
      default: ''
    },

    Newtotal: {
      type: Number,
      default: ''
    },

    Newpagedangqianye: {
      type: Number,
      default: ''
    },
    Newname: {
      type: Number, //会员名录1 政策法规2  信息披露3
      default: ''
    }
  },
  data() {
    return {
      //分页当前页
      pagedangqianye: 1,
      total: '',
      //只有一页就隐藏true
      isPage: true,
      data: [],
      //判断是哪一个进来的
      namestr: 1,

      //表格头部内容
      titlename: '',
      titletime: '',
      titleriqi: '',

      //取值
      propdata: 'data',
      propname: 'name',
      proptime: 'createTime'
    };
  },

  created() {
    this.namestr = this.Newname;
    this.data = this.Newdata;

    this.total = this.Newtotal;
    this.pagedangqianye = this.Newpagedangqianye;

    if (this.namestr == 1) {
      this.titlename = '会员名称';
      this.titletime = '加入时间';
      this.titleriqi = '';

      this.propdata = '';
      this.propname = 'name';
      this.proptime = 'createTime';
    } else if (this.namestr == 2) {
      this.titlename = '标题';
      this.titletime = '时间';
      this.titleriqi = '日期';
      this.propdata = 'dateStr';
      this.propname = 'title';
      this.proptime = 'createTime';
    } else if (this.namestr == 3) {
      this.titlename = '标题';
      this.titletime = '时间';
      this.titleriqi = '日期';
      this.propdata = 'dateStr';
      this.propname = 'title';
      this.proptime = 'createTime';
    }

  },
  methods: {
    //分页跳转
    handleSizeChange(val) {
    },
    handleCurrentChange(val) {
      //刷新数据
      this.$emit('WLpageindex', val);
    },
    //回调详情
    cellxiangqing(event) {
      // console.log(event)
      this.$emit('WLcellClick', event);
    }
  }
};
</script>

<style  lang="less" >
.tablediv {
  width: 1200px;
  max-height: 920px;
  padding: 30px;

  background-color: #ffffff;
  margin-bottom: 20px;


  .el-pagination button:disabled {
      color: #C0C4CC;
      background-color: #FFF;
      cursor: not-allowed;
      background-color: #F0F0F0;
  }
  .el-pagination .btn-next, .el-pagination .btn-prev {

      background: center center no-repeat #FFF;
      background-size: 16px;
      cursor: pointer;
      margin: 0;
      color: #FFFFFF;
      background-color: #1d3f95;
      border-radius: 14px;
  }
  .el-pagination button {
     text-align: center;
      border: none;
      padding: 0 6px;
      width: 70px;
  }

  .el-input__inner {
      -webkit-appearance: none;
      background-color: #FFF;
      background-image: none;
      border-radius: 14px;
      background-color: #1d3f95;

      border: 0px solid #DCDFE6;
      box-sizing: border-box;
      color: #FFFFFF;
      display: inline-block;
      font-size: inherit;
      height: 40px;
      line-height: 40px;
      outline: 0;
      padding: 0 15px;
      transition: border-color .2s cubic-bezier(.645,.045,.355,1);
      width: 100%;
  }

  .el-pager li.active {
      color: #1d3f95;
      cursor: default;
  }
  .el-pagination {
      white-space: nowrap;
      padding: 2px 5px;
      color: #999999;
      font-weight: 700;
  }

}
.wlmainW {
  width: 1200px;
}
.datadiv {
  width: 30px;
  height: 30px;
  background-color: #ececec;
  border-radius: 10px 0px 10px 0px;
  padding-top: 3px;
  color: #1d3f95;
  font-size: 16px;
  font-weight: bold;
}

</style>
